home *** CD-ROM | disk | FTP | other *** search
- {@@@@@ TIMER routine by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
- { To use it, just put a "timer(on)" where you want to start timing and
- a "timer(off)" at the end. The time (in seconds, "accurate" to the
- 1/100 of a second) resides in the real variable "time".
-
- The timer routine itself takes about 4 milliseconds, so for serious
- timing, you probably want to time 1000 or 10000 repetitions of the
- event. A typical scenario:
-
- write('1000 repetitions of <whatever> takes ');
- timer(on);
- for N := 1 to 1000 do
- <whatever>;
- timer(off);
- writeLn(time:1:2);
-
- }
- type
- OnOrOff = (On,Off);
- var
- start, time : real;
- {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
- procedure timer(O : OnOrOff);
- type
- regpack = record
- ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
- end;
-
- var
- recpack : regpack;
- hour,min,sec,hun : integer;
-
- begin
- with recpack do
- begin
- ax := $2C shl 8;
- end;
- intr($21,recpack); {call interrupt}
- with recpack do
- begin
- hour := cx shr 8;
- min := cx and $FF;
- sec := dx shr 8;
- hun := dx and $FF;
- end;
- if O = On then
- begin
- start := hour * 3600 + min * 60 + sec + hun/100;
- time := 0;
- end
- else
- begin
- time := hour * 3600 + min * 60 + sec + hun/100 - start;
- start := 0;
- end;
- end;
-
-